package com.ewei.web.crawler.dao;

import org.bson.Document;

import com.mongodb.client.MongoCollection;

/**
 * 用于同步缓存到数据库集合中
 * @author David
 *
 */
public class SyncThread<T> implements Runnable {
	private Cache<T> cache = null;
	private boolean isClose = false;
	public SyncThread(Cache<T> cache){
		this.cache = cache;
	}
	@Override
	public void run() {
		while(true){
			if(!isClose){
				cache.sync();
			}
		}
	}
	public void close(){
		isClose = true;
	}
}
